home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / haze.vp < prev    next >
Text File  |  2003-02-17  |  2KB  |  59 lines

  1. !!VP1.0
  2.  
  3. # c[0]..c[3] contains the concatenation of the modelview and projection matrices.
  4. # c[4]..c[7] contains the inverse transpose of the modelview
  5. # c[15] contains the eye position in object space
  6. # c[16] contains the light direction in object space
  7. # c[17] contains H, the normalized sum of the eye and light direction
  8. # c[20] contains the light color * object color
  9. # c[32] contains the ambient light color * object color
  10. # c[33] contains the haze color
  11. # c[40] contains (0, 1, 0, specPower)
  12. # v[OPOS] contains the per-vertex position
  13. # v[NRML] contains the per-vertex normal
  14. # v[TEX0] contains the per-vertex texture coordinate 0
  15. # o[HPOS] output register for homogeneous position
  16. # o[TEX0] output register for texture coordinate 0
  17. # o[COL0] output register for primary color
  18. # R0...R11 temporary registers
  19.  
  20. # Transform the vertex by the modelview matrix
  21. DP4   R1.x, c[0], v[OPOS];
  22. DP4   R1.y, c[1], v[OPOS];
  23. DP4   R1.z, c[2], v[OPOS];
  24. DP4   R1.w, c[3], v[OPOS];
  25.  
  26. # Compute the diffuse light component
  27. DP3   R2, v[NRML], c[16];
  28. # Clamp the diffuse component to zero
  29. MAX   R2.x, R2, c[40].xxxx;
  30.  
  31. # Get the vector from the eye to the vertex
  32. ADD   R4, c[15], -v[OPOS];
  33.  
  34. # Normalize it
  35. DP3   R0.w, R4, R4;
  36. RSQ   R0.w, R0.w;
  37. MUL   R4.xyz, R4, R0.w;
  38.  
  39. # Haze
  40. DP3   R2.y, v[NRML], R4;
  41. ADD   R2.y, c[40].y, -R2.y;
  42. # MUL   R2.y, R2.x, R2.y;
  43. MUL   o[FOGC].x, R2.x, R2.y;
  44.  
  45. # Output the texture
  46. MOV   o[TEX0], v[TEX0];
  47.  
  48. # Output the primary color
  49. MOV   R0, c[32];
  50. MAD   o[COL0], c[20], R2.xxxx, R0;
  51.  
  52. # MUL   o[COL1], R2.y, c[33];
  53.  
  54. # Output the vertex
  55. MOV   o[HPOS], R1;
  56.  
  57. END
  58.  
  59.